package cn.lizemin.demo.thread.innerClass;

import cn.lizemin.demo.thread.blocked.A;

import java.util.Comparator;

/**
 * @author: lizemin
 * @version: 1.0
 */
public class TestOuter {
    int age = 20;
    double height = 170;
    private Object obj;

    public void sleep(){
        System.out.println("test......sleep");

    }
    public void test(){
        int num = 10;
        //局部内部类
        class InnerLocal{
            int money = 20;
            public void play(){
                //局部内部类中的属性不能在其函数中进行重新赋值。
                System.out.println(num);
                //可以直接访问外部类的属性
                System.out.println(age);
                System.out.println(money);
                sleep();
                System.out.println(height);
                synchronized(obj){

                }

            }

        }
        //创建内部类的对象，并调用
        InnerLocal innerLocal = new InnerLocal();
        innerLocal.play();

    }
    //匿名内部类
    public Comparable test2(){
        return new Comparable() {
            @Override
            public int compareTo(Object o) {
                return 20;
            }
        };
    }

}
